﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;

namespace WAT
{
    // Note: For instructions on enabling IIS6 or IIS7 classic mode, 
    // visit http://go.microsoft.com/?LinkId=9394801

    public class MvcApplication : System.Web.HttpApplication
    {
        public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

            routes.MapRoute("AdminUserRole", "Admin/UserRole/List/{page}",
                new
                {
                    controller = "UserRole",
                    action = "List",
                    page = "0"
                },
                new
                {
                    controller = "UserRole",
                    page = @"\d+"
                });
            routes.MapRoute("AdminUserRoleAction", "Admin/UserRole/{action}/{role}",
                new
                {
                    controller = "UserRole",
                    action = "List",
                    role = ""
                },
                new
                {
                    controller = "UserRole"
                });

            routes.MapRoute("AdminUser", "Admin/User/List/{page}",
                new
                {
                    controller = "User",
                    action = "List",
                    page = "0"
                },
                new
                {
                    controller = "User",
                    page = @"\d+"
                });
            routes.MapRoute("AdminUserAction", "Admin/User/{action}/{username}",
                new
                {
                    controller = "User",
                    action = "",
                    username = ""
                });

            routes.MapRoute("Admin", "Admin",
                new
                {
                    controller = "Admin",
                    action = "Index"
                });

            routes.MapRoute("Home", "Home",
                new
                {
                    controller = "Home",
                    action = "Index"
                });
            routes.MapRoute("HomeAbout", "Home/About",
                new
                {
                    controller = "Home",
                    action = "About"
                });

            routes.MapRoute(
                "Default",                                      // Route name
                "{controller}/{action}/",                       // URL with parameters
                new { controller = "Admin", action = "Index" }  // Parameter defaults
            );
        }

        protected void Application_Start()
        {
            RegisterRoutes(RouteTable.Routes);
        }
    }
}